import { PORT1 } from "@/config/servicePort";
import request from "@/utils/request";
import { AxiosPromise } from 'axios';
import { UserQuery, UserPageVO, UserForm } from './types';

/**
 * @name 用户管理模块
 */
export function getUserList(data: UserQuery): AxiosPromise<ResultData<UserPageVO[]>> {
  return request({
    url: PORT1 + `/user/list`,
    method: 'post',
    data
  });
}

// 添加用户
export const addUser = (data: UserForm) => {
  return request({
    url: PORT1 + `/user`,
    method: 'post',
    data
  });
};

// 编辑用户
export const updateUser = (data: UserForm) => {
  return request({
    url: PORT1 + `/user`,
    method: 'put',
    data
  });
};

// // 删除用户
export const deleteUser = (params: number[]) => {
  const str = params.join()
  return request({
    url: PORT1 + `/user/delete/${str}`,
    method: 'delete',
  });
};